<#include "../common/layout/__mainlayout.html">
<#include "../common/__pagination.html">

    <!--设置面包屑-->
    <#assign pageBreadCrumbs>
        <li class="active"><a href="#">客户端管理</a></li>
        <li class="active"><a href="#">客户端管理</a></li>
    </#assign>


    <#assign pageCss>
        <!-- page specific plugin styles -->
        <link rel="stylesheet" href="${ctx}/static/admin/assets/css/jquery-ui.custom.css"/>
        <link rel="stylesheet" href="${ctx}/static/admin/assets/css/chosen.css"/>
        <link rel="stylesheet" href="${ctx}/static/admin/assets/css/datepicker.css"/>
        <link rel="stylesheet" href="${ctx}/static/admin/assets/css/daterangepicker.css"/>
        <link rel="stylesheet" href="${ctx}/static/admin/assets/css/daterangepicker.css"/>

    </#assign>

    <#assign pageJavascript>
        <script type="text/javascript">
            $(document).ready(function () {
                //初始化范围选择器
                $('input[name=publishDateRange]').daterangepicker({
                    'applyClass' : 'btn-sm btn-success',
                    'cancelClass' : 'btn-sm btn-default',
                    locale: {
                        applyLabel: '确定',
                        cancelLabel: '取消'
                    }
                });

                $("#clientType").val(${query.clientType!});
                $("#channelId").val(${query.channelId!});


                $('[data-rel=tooltip]').tooltip();

                if (!ace.vars['touch']) {
                    $('.chosen-select').chosen({allow_single_deselect: true});
                }

                // 清除远程modal数据
                $("#editModal").on("hidden.bs.modal", function () {
                    $(this).removeData("bs.modal");
                });

                // 删除按钮
                $("a.delete").on(ace.click_event, function (e) {
                    submitClickListener(this,e,"删除");
                });

                // 上架按钮
                $("a.upState").on(ace.click_event, function (e) {
                    submitClickListener(this,e,"上架");
                });

                // 下架按钮
                $("a.downState").on(ace.click_event, function (e) {
                    submitClickListener(this,e,"下架");
                });

                function submitClickListener(obj,e,title){
                    var currentA = obj;
                    e.preventDefault();
                    bootbox.confirm({
                                message: "确定"+title+"该客户端?",
                                buttons: {
                                    confirm: {
                                        label: "确定",
                                        className: "btn-primary btn-sm"
                                    },
                                    cancel: {
                                        label: "取消",
                                        className: "btn-sm"
                                    }
                                },
                                callback: function (result) {
                                    if (result) {
                                        url = $(currentA).attr("href");
                                        $.get(url, { },function(data){
                                            if(data){
                                                window.location.href=window.location.href;
                                            }
                                        });
                                    }
                                }
                            }
                    );
                }



            });
        </script>
    </#assign>


    <@mainlayout pageBreadCrumbs=pageBreadCrumbs pageCss=pageCss pageJavascript=pageJavascript
        currentMenu="ClientFlag-clintVersionListFlag">

            <form id="searchForm" class="form-search form-inline" action="${ctx}/admin/client/list.html">
                <div class="row">
                    <div class="widget-body">
                        <div class="widget-main">
                            <div class="form-group col-xs-12" style="padding-top:10px">
                                <label class="col-xs-1 text-right" for="clientType">版本类型:</label>
                                <select class="col-xs-2"  name="clientType" id="clientType"  data-placeholder="Choose a State...">
                                    <option value="-99" >请选择</option>
                                    <option value="0">通用</option>
                                    <option value="1">定制</option>
                                </select>

                                <label class="col-xs-1 text-right" for="channelId">渠道商:</label>
                                <select class="col-xs-2"  name="channelId" id="channelId" data-placeholder="Choose a State...">
                                    <option value="-99" >请选择</option>
                                    <#list channels as channel>
                                        <option value="${channel.id}" >
                                            ${(channel.channelName)!}
                                        </option>
                                    </#list>
                                </select>

                                <label class="col-xs-1 text-right" for="publishDateRange">上架时间:</label>
                                <div class="input-medium input-group">
                                    <input class="form-control col-xs-2" type="text" class="input-sm input-small"　value="${query.publishDateRange!}" 　 name="publishDateRange" id="publishDateRange"/>
                                </div>
                                &nbsp;&nbsp;&nbsp;
                                <input type="submit" id="searchBtn" class="btn btn-sm btn-primary" value="查询"/>

                            </div>

                        </div>
                    </div>
                </div>
            </form>
            <table id="contentTable" class="table table-striped table-bordered table-hover">
                <thead>
                <tr>
                    <th width="62" align="center">软件名称</th>
                    <th width="40" align="center">软件包名</th>
                    <th width="60" align="left">版本名称</th>
                    <th width="60" align="left">版本号</th>
                    <th width="40" align="left">版本类型</th>
                    <th width="40" align="left">国家</th>
                    <th width="40" align="left">运营商名称</th>
                    <th width="40" align="left">固件</th>
                    <th width="40" align="left">上架时间</th>
                    <th width="70" align="center">操作</th>
                </tr>
                </thead>
                <tbody>
                    <#list clients.listData as client>
                        <#if client??>
                            <tr>
                                <td width="60" align="left">${client.clientName!}</td>
                                <td width="60" align="left">${client.packageName!}</td>
                                <td width="40" align="left">${client.versionName!}</td>
                                <td width="60" align="left">${client.versionCode!}</td>
                                <td width="40" align="left">${client.clientType!}</td>
                                <td width="40" align="left">${client.language!}</td>
                                <td width="40" align="left">${client.categoryId!}</td>
                                <td width="40" align="left">${client.channelId!}</td>
                                <td width="40" align="left">${client.publishTimeShow!}</td>
                                <td>
                                    <div class="hidden-sm hidden-xs action-buttons">
                                        <a class="green tooltip-success view" onclick='reload("${ctx}/admin/client/view.do?id=${client.id!}");return false;'  data-rel="tooltip" title="查看"><span class="label label-default">查看</span></a>
                                        <a class="green tooltip-success edit" onclick='reload("${ctx}/admin/client/edit.do?id=${client.id!}");return false;'   href="${ctx}/admin/client/edit.do?id=${client.id!}" data-rel="tooltip" title="编辑"><span class="label label-success">编辑</span></a>
                                        <a class="red tooltip-error delete"  href="${ctx}/admin/client/del.do?id=${client.id!}" data-rel="tooltip" title="删除"> <span class="label label-danger">删除</span> </a>
                                        <#if client.state != 1 >
                                            <a class="green tooltip-warning upState" href="${ctx}/admin/client/upClient.do?id=${client.id!}"  data-rel="tooltip" title="上架" > <span class="label label-warning">上架</span></a>
                                            <#else>
                                                <a class="green tooltip-warning downState" href="${ctx}/admin/client/downClient.do?id=${client.id!}"  data-rel="tooltip" title="下架" > <span class="label label-warning">下架</span></a>
                                        </#if>

                                    </div>
                                </td>

                            </tr>
                        </#if>
                    </#list>
                </tbody>
            </table>
            <@pagination clients!/>
    <div id="editModal" class="modal fade">
        <div class="modal-dialog"style="width: 1200px;">
            <div class="modal-content">
            </div>
        </div>
    </div>
</@mainlayout>